<?php
include LIB_PATH.'vendor/smarty/Smarty.class.php';
class template extends Smarty{
    
    public function __construct(){
        parent::__construct();
        $this->template_dir = APP_PATH.'tpl'.DS;
        $this->compile_dir = CACHE_PATH.'compiled';
        $this->cache_dir = CACHE_PATH.'filecache';
    }
    
    public function display($template = null, $cache_id = null, $compile_id = null, $parent = null){
        if(empty($template)) $template=M_NAME.'/'.C_NAME.'/'.A_NAME;//默认
        elseif(strpos($template,'/')===0){
            $template=trim($template,'/');//跨模块
        }else{
            $path=explode('/',$template);
            if(count($path)<3) $template=M_NAME.'/'.$template;//当前模块相对路径
        }
        if(strpos($template,'.')===false) $template.='.'.C('MB_EXT');
        parent::display($template, $cache_id, $compile_id, $parent, 1);
    }

} 